838D - Airplane Arrangements - CodeForces Solution


math number theory *2700

Please click on ads to support us..

Python Code:

n,m=[int(i) for i in input().split()]
print(pow(2*n+2,m-1,1000000007)*2*(n+1-m)%1000000007)

C++ Code:

#include <bits/stdc++.h>

using namespace std;

inline int read()
{
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-') f=1;ch=getchar();}
	while(ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return f?-x:x;
}

#define x first
#define y second

typedef pair<int,int> PII;
typedef long long LL;
const int N=1e6+10,MOD=1e9+7;

int n,m;

int qmi(int x,int k)
{
	int res=1;
	while(k){
		if(k&1) res=res*1ll*x%MOD;
		x=x*1ll*x%MOD,k>>=1;
	}
	return res;
}

int main()
{
	n=read(),m=read();
	printf("%d\n",qmi(2,m)*1ll*(n-m+1)%MOD*qmi(n+1,m-1)%MOD);
	
	return 0;
}

     	   		      		     					 	


Comments

Submit
0 Comments
More Questions

510B - Fox And Two Dots
616D - Longest k-Good Segment
1604A - Era
555B - Case of Fugitive
551A - GukiZ and Contest
1399F - Yet Another Segments Subset
1371C - A Cookie for You
430B - Balls Game
1263A - Sweet Problem
1332B - Composite Coloring
254A - Cards with Numbers
215A - Bicycle Chain
1288B - Yet Another Meme Problem
1201C - Maximum Median
435A - Queue on Bus Stop
1409B - Minimum Product
723B - Text Document Analysis
1471C - Strange Birthday Party
1199A - City Day
1334A - Level Statistics
67B - Restoration of the Permutation
1734A - Select Three Sticks
1734B - Bright Nice Brilliant
357B - Flag Day
937A - Olympiad
1075A - The King's Race
1734C - Removing Smallest Multiples
1004C - Sonya and Robots
922A - Cloning Toys
817A - Treasure Hunt